js simulate click

137

js simulate click -

document.getElementById('elementID').click();

javascript simulate click on element -

function eventFire(el, etype){
  if (el.fireEvent) {
    el.fireEvent('on' + etype);
  } else {
    var evObj = document.createEvent('Events');
    evObj.initEvent(etype, true, false);
    el.dispatchEvent(evObj);
  }
}
//usage
eventFire(document.getElementById('mytest1'), 'click');

javascript perform click -

function eventFire(el, etype){
  if (el.fireEvent) {
    el.fireEvent('on' + etype);
  } else {
    var evObj = document.createEvent('Events');
    evObj.initEvent(etype, true, false);
    el.dispatchEvent(evObj);
  }
}

javascript perform click -

eventFire(document.getElementById('mytest1'), 'click');

Comments

Submit
0 Comments